<template>
	<view class="login_content">
		
		<view class="form_content">

			<uni-easyinput placeholderStyle="font-size: 30rpx;" style="margin-bottom: 40rpx;" prefixIcon="phone" type="text" v-model="formData.phone" placeholder="请输入手机号码" />

			<uni-easyinput placeholderStyle="font-size: 30rpx;" style="margin-bottom: 40rpx;" type="password" prefixIcon="locked" v-model="formData.oldPassword" placeholder="请输入旧密码" />

			<uni-easyinput placeholderStyle="font-size: 30rpx;" style="margin-bottom: 40rpx;" type="password" prefixIcon="locked" v-model="formData.verifyPassword" placeholder="请输入新密码" />

			<uni-easyinput placeholderStyle="font-size: 30rpx;" style="margin-bottom: 40rpx;" type="password" prefixIcon="locked" v-model="formData.SecondaryPassword" placeholder="请再次输入新密码" />

			
			<button hover-class="hover_btn" @click="changePassword">修改密码</button>
		</view>

		<view class="login_footer">
			<view>义乌市弘兆信息技术有限公司</view>
			<view @click="makePhoneCall">销售热线：17855898445</view>
		</view>

	</view>
</template>
<script>
	import Http from '@/service/api'
	export default {
		data() {
			return {
				token: '',
				customId: '',
				dk: '',

				loading: false,

				baseUrl: '', // 服务地址  jinmiaompro.ywhzsoft.com/JinMiaoPbkdTest
				updateUrl: '', // 更新地址
				formData: {},
			};
		},
		onLoad() {
			//获取缓存账号
			this.dk = this.$baseURL

		},
		methods: {
			changePassword() {
				if (!this.formData.phone) {
					uni.showToast({
						title: '请输入手机号码',
						icon: 'none'
					});
					return;
				}
				if (!this.formData.oldPassword) {
					uni.showToast({
						title: '请输入旧密码',
						icon: 'none'
					});
					return;
				}

				if (this.formData.verifyPassword !== this.formData.SecondaryPassword) {
					uni.showToast({
						title: '两次新密码与密码不一致',
						icon: 'none'
					});
					return;
				}

				let param = {
					...this.formData,
					customId: uni.getStorageSync('customId'),
				}

				console.log('== param ', param)
				
				Http.updatePassWordMallUser(JSON.stringify(param)).then(r => {
					uni.showToast({
						title: '密码更新成功',
						icon: 'none'
					});
					// 返回上一页
					setTimeout(() => {
						uni.navigateBack({
							delta: 1
						})
					}, 900)

				}).catch( err => {
					console.log('== err ', err)
					uni.showToast({
						title: err.message,
						icon: 'none'
					});
				})
					
			},

            // 底部拨打电话
			makePhoneCall() {
				uni.makePhoneCall({
					phoneNumber: '17855898445' //仅为示例
				});
			},
		},
	}
</script>

<style lang="scss" scoped>
	.login_content {
		width: 100vw;
		height: 100vh;
		display: flex;
		flex-direction: column;

		.header_img {
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			height: 40%;
		}

		.form_content {
			flex: 1;
			background: #fff;
			padding: 20rpx;

			/deep/.uni-easyinput__content-input {
				height: 80rpx;
			}

			.http_config {
				display: flex;
				align-items: center;
				background: #bbb;
				padding: 10rpx 15rpx;
				color: #fff;
				border-radius: 20rpx;
				font-size: 20rpx;
				.iconfont {
					font-size: 20rpx;
					margin-right: 10rpx;
				}
			}

			/deep/.content-clear-icon {
				font-size: 40rpx !important;
			}
			/deep/.uni-input-input {
				font-size: 30rpx;
			}

			button {
				display: flex;
				align-items: center;
				justify-content: center;
				background: #f9a94d;
				height: 60rpx;
				color: #fff;
				font-size: 30rpx;
				margin-bottom: 25rpx;
				border-radius: 30rpx;
			}

			.hover_btn {
				background: #e09845;
			}
		}

		.login_footer {
			color: #9e9e9e;
			font-size: 15rpx;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			height: 80rpx;
		}
	}

    .config_popup {
        width: 80vw;
        background: #fff;
        border-radius: 15rpx;
        padding: 40rpx;

        .config_title {
            margin-bottom: 40rpx;
            font-size: 40rpx;
        }

        .config_item {
            display: flex;
            align-items: center;
            margin-bottom: 20rpx;
            font-size: 30rpx;
            input {
                flex: 1;
                border: 1rpx solid #ccc;
                padding: 10rpx 20rpx;
                margin: 0 20rpx;
            }
            .iconfont {
                font-size: 50rpx;
            }
        }

        .config_button {
            display: flex;
            align-items: center;
            margin-top: 40rpx;

            button {
                display: flex;
                align-items: center;
                justify-content: center;
				font-size: 30rpx;
                width: 200rpx;
                height: 60rpx;
            }

            button:nth-child(1) {
                background: #009fd9;
                color: #fff;
            }
            .hover_save {
                background: #047fac !important;
                
            }
        }
    }
</style>